Android™ Wireless Application Development Volume II: Advanced Topics, Third Edition (Shawn Kahl's Library) by Lauren Darcey & Shane Conder

Android™ Wireless Application Development Volume II: Advanced Topics, Third Edition (Shawn Kahl's Library) by Lauren Darcey & Shane Conder

Author:Lauren Darcey & Shane Conder
Language: eng
Format: epub
Publisher: Addison-Wesley Professional
Published: 2012-06-12T16:00:00+00:00


message += part.

getDisplayMessageBody();

if (sender == null) {

sender = part.

getDisplayOriginatingAddress();

}

}

receivedMessage.setText(

message + "\nFrom: "+sender);

numberEntry.setText(sender);

}

}

};

registerReceiver(rcvIncoming, new IntentFilter(

"android.provider.Telephony.SMS_RECEIVED"));

This block of code is placed in the onCreate() method of the Activity. First, the message Bundle is retrieved. In it, an array of Objects holds several byte arrays that contain PDU data—the data format that is customarily used by wireless messaging protocols. Luckily, the Android SDK can decode these with a call to the static SmsMessage.createFromPdu() utility method. From here, we can retrieve the body of the SMS message by calling getDisplayMessageBody().

The message that comes in might be longer than the limitations for an SMS. If it is, it will have been broken up in to a multipart message on the sending side. To handle this, we loop through each of the received Object parts and take the corresponding body from each, while only taking the sender address from the first.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.